<template>
	<view>
		<view class="dataItem">当前推荐人：{{parent?parent.nickname:'无'}}</view>
		<view class="dataItem">城市运营商：美试客</view>
		<input class="dataItem" placeholder="请输入邀请码" v-model="code">
		
		<!-- <view v-if="info" class="tips" style="margin-top: 10upx;">邀请人：刘佳阳</view> -->
		<view class="tips">成为经销商后的用户不能修改</view>
		<view class="buyBtn" @click="toSave">确定修改</view>
	</view>
</template>

<script>
	
	import {
		post,
		abortPost,
		get
	} from '@/utils/post.js'
	export default {
		data(){
			return {
				parent:'',
				code:'',
				info:''
			}
		},
		onLoad(){
			this.getUser()
		},
		
		methods:{
			getUser(){
				get(this.$api.wx.parent_info,{},true,res=>{
					this.parent = res.data.parent
				})
			},
			toSave(){
				if(!this.code) return
				post(this.$api.wx.parent_edit,{
					invite_code:this.code
				},true,res=>{
					if(res.code == 0){
						this.getUser()
					}else{
						this.$showM(res.msg,false)
					}
				})
			}
		}
	}
</script>

<style scoped>
	.buyBtn {
		width: 600upx;
		margin: 100upx auto 0;
		line-height: 70upx;
		text-align: center;
		color: #fff;
		font-size: 30upx;
		background-image: linear-gradient(to right, #ffd171, #ff8959);
		border-radius: 10upx;
	}
	.dataItem{
		width: 600upx;
		line-height: 70upx;
		height: 70upx;
		font-size: 30upx;
		margin: 100upx auto 0;
		border-bottom: 1px solid #ccc;
	}
	.tips{
		width: 600upx;
		margin: 50upx auto 0;
		font-size: 26upx;
		color: #ff7192;
	}
	page{
		background: #fff;
	}
</style>
